<template>
	<view class="index">

		<!-- 商品分类结束 -->
		<goods-list :goods="recommendGoods" showType="2"></goods-list>

	</view>
</template>

<script>
	import uniIcon from '../../components/uni-icon.vue';
	import goodsList from '../../components/goods-list.vue';
	import Request from '../../common/request.js';

	

	export default {
		components: {
			uniIcon, goodsList 	
		},
		data() {
			return {
				recommendGoods: [],
				cateId: '',
				page: 1,
				nextPage: true
			}
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title:options.title
			})
			this.cateId = options.id;
			this.getGoods();
			
		},
		methods: {
			scroll: function(e) {
				console.log(e)
				// this.old.scrollTop = e.detail.scrollTop
			},


			//获取推荐商品
			getGoods: function(callback) {
				var that = this;
				if(this.nextPage == false){
					return false;
				}
				var pararms = {
					url: 'category/getCategoryGoods',
					data: {
						page: that.page,
						id: that.cateId,
					},
					sCallback: function(res) {
						that.recommendGoods = that.recommendGoods.concat(res.data);
						that.page ++;
						if(res.data.length < 20) {
							that.nextPage = false;
						}
						
						callback && callback();
					}
				}


				Request.send(pararms);
			}
			
		},
		onReachBottom() {
			this.getGoods();
		}
	}
</script>

<style>

	.index {
		width: 100%;
		background: #F5F5F5;
	}

	
</style>
